package cn.i7baozh;

import cn.i7baozh.dto.HiPropertiesDTO;
import cn.i7baozh.service.HiService;
import cn.i7baozh.service.impl.CustomHiService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author zhangbaoqi532
 * @date 2025/1/13
 */
// 配置中需要有xxx1.xxx2.xx3=xx4这个配置（matchIfMissing 表示没有这个值返回true还是false 。如果是true就是不需要设置这个值也能用，如果是false，就必须设置这个值才能用）
@ConditionalOnProperty(prefix = "xxx1.xxx2", name = "xx3", havingValue = "xx4")
//@ConditionalOnMissingBean(HiService.class) //spring容器中不存在这个服务的时候才初始化
@EnableConfigurationProperties(HiPropertiesDTO.class) //指定配置类
public class TestAutoConfigurationWithProperties {

    @Bean
    public HiService hiService(){
        return new CustomHiService();
    }
}
